<template>
  <div>
    <div class="pltxt">{{setName}} <span v-if="setUntil!=undefined">({{setUntil}})</span></div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="setValue_parent"
        type="text" 
        show-error 
        clearable
        name="validator"
        :rules="[{ validator,message: `${$t('Range')}：${setMin}-${setMax}` }]"
        @clear="$emit('update:setValue','')"
      >
      <template #button>
        <van-button size="small" round class="setbtn">{{$t('Save')}}</van-button>
      </template>
      </van-field>
    </van-form>
  </div>
</template>

<script>

export default {
  props:['setName','setUntil','setValue','setMin','setMax','reg'],
  data(){
    return {
      setValue_parent:this.setValue,
    }
  },
  watch:{
    setValue(newVal){
      this.setValue_parent=newVal;
    }
  },
  methods: {
    validator(val){
      return this.comm.fixedTwo(val,this.setMin,this.setMax);
    },
    onSubmit(){
      this.comm.setDataPT(1,[{'reg':this.reg,'val':this.comm.mulFunction(this.setValue_parent,100)}]);
    }
  }
}
</script>

<style scoped lang="less">

</style>